package jp.co.jalinfotec.sxt.entity;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

/** User Entity */
@PersistenceCapable(identityType=IdentityType.APPLICATION)
public class UserEntity {

	/** Internal key */
	@PrimaryKey
	@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
	private Key internalKey;
	
	/**
	 * [Setter]Internal key
	 * @param internalKey Internal key
	 */
	public void setInternalKey(Key internalKey) { this.internalKey = internalKey; }

	/**
	 * [Getter]Internal key
	 * @return Internal key
	 */
	public Key getInternalKey() { return this.internalKey; }
	
	/** User ID */
	@Persistent
	private String id;
	
	/**
	 * [Setter]User ID
	 * @param id User ID
	 */
	public void setId(String id) { this.id = id; }

	/**
	 * [Getter]User ID
	 * @return User ID
	 */
	public String getId() { return this.id; }
	
	/** User Name */
	@Persistent
	private String name;
	
	/**
	 * [Setter]User Name
	 * @param name User Name
	 */
	public void setName(String name) { this.name = name; }

	/**
	 * [Getter]User Name
	 * @return User Name
	 */
	public String getName() { return this.name; }
	
	/** Password */
	@Persistent
	private String password;
	
	/**
	 * [Setter]Password
	 * @param password Password
	 */
	public void setPassword(String password) { this.password = password; }

	/**
	 * [Getter]Password
	 * @return Password
	 */
	public String getPassword() { return this.password; }
	
	/** Default Constructor */
	public UserEntity(){}
	
	/**
	 *Create internal key
	 * @param userId User ID
	 * @return Key object
	 */
	public static Key createKey(String userId){
		return new KeyFactory.Builder(
				UserEntity.class.getSimpleName(),
				UserEntity.class.getSimpleName()+userId).getKey();
	}
}
